package com.onlineMIS.ORM.entity.headQ.report;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;

import com.onlineMIS.action.headQ.report.HeadQReportFormBean;
import com.onlineMIS.common.Common_util;
import com.onlineMIS.common.ExcelTemplate;

public class HeadqDealingsReportTemplate extends ExcelTemplate {
		
	private List<HeadQDealingsReportVO> list = new ArrayList<HeadQDealingsReportVO>();
	private Date startDate = null;
	private Date endDate = null;

	public HeadqDealingsReportTemplate(String templateWorkbookPath,List<HeadQDealingsReportVO> list,HeadQReportFormBean formBean) throws IOException {
		super(templateWorkbookPath);
		this.list =  list;
		this.startDate = formBean.getStartDate();
		this.endDate = formBean.getEndDate();
	}
	
	
	public HSSFWorkbook process() {
		HSSFSheet sheet = templateWorkbook.getSheetAt(0);
		
		Row dateRow = sheet.getRow(1);
		dateRow.createCell(1).setCellValue(Common_util.dateFormat.format(startDate));
		dateRow.createCell(2).setCellValue(Common_util.dateFormat.format(endDate));

		for (int i = 0; i < list.size(); i++) {
			HeadQDealingsReportVO item = list.get(i);
			Row row = sheet.createRow(i + 3);
			row.createCell(0).setCellValue(item.getClientId());
			row.createCell(1).setCellValue(item.getClientName());
			row.createCell(2).setCellValue(item.getCtpDebt()); 
			row.createCell(3).setCellValue(item.getCtpPrestore()); 
			row.createCell(4).setCellValue(item.getMidtermPayment()); 		
			row.createCell(5).setCellValue(item.getMidtermConsumption()); 
			row.createCell(6).setCellValue(item.getMidtermRecharge()); 
			row.createCell(7).setCellValue(item.getMidtermSale()); 
			row.createCell(8).setCellValue(item.getMidtermReturn()); 
			row.createCell(9).setCellValue(item.getEndDebt()); 
			row.createCell(10).setCellValue(item.getEndPrestore()); 
			row.createCell(11).setCellValue(item.getNowDebt()); 
			row.createCell(12).setCellValue(item.getNowPrestore()); 
			

		}
		return templateWorkbook;
	}

}
